package com.kzy.demoadmin.web.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kzy.demoadmin.web.entity.Log;
import com.kzy.demoadmin.web.exception.BizException;
import com.kzy.demoadmin.web.mapper.LogMapper;
import com.kzy.demoadmin.web.service.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;

    /**
     * 根据id查询
     * @param integer
     * @return
     */
    @Override
    public Log findById(Integer integer) {
        return logMapper.findById(integer);
    }

    /**
     * 分页查询
     * @param log
     * @return
     */
    @Override
    public PageInfo<Log> getLogList(Log log) {
        PageHelper.startPage(log.getPageNo(), log.getPageSize());
        List<Log> list = logMapper.searchBy(log);
        return new PageInfo<>(list);
    }

    /**
     * 删除审批
     * @param id
     * @return
     */
    @Override
    public int deleteById(Integer id) {
        return logMapper.deleteById(id);
    }

    /**
     * 新增日志
     * @param log
     */
    @Override
    public void add(Log log) {
        logMapper.insert(log);
    }

    /**
     * 修改日志
     * @param log
     */
    @Override
    public void edit(Log log) {
        logMapper.update(log);
    }
}
